<%@ page pageEncoding="UTF-8"%>
<%@ include file="/common/common.jsp"%>
<%
	//病人查询
	String cardNumber = input.getDesc("cardNumber","320222195108041872");
	String patientName = input.getDesc("patientName","章国清");
	String hql = "select distinct new map( zy.patid as patid , zy.mzh as mzh , zy.hzxm as hzxm , zy.sfzh as sfzh ,zy.sex as sex ,zy.ksdm as ksdm ,dept.name as deptName, zy.bqdm as bqdm , bq.name as bqmc , zy.ysdm as ysdm,yy.name as doctorName , zy.cwdm as cwdm ,zy.ryrq as ryrq ,zy.cyrq as cyrq ,zy.wzjb as wzjb, zy.ryfs as ryfs , zy.cyfs as cyfs , zy.memo as memo , zy.ssdm1 as ssdm1 , zy.ssdm2 as ssdm2 )"+
	"from ZY_BRSYK zy ,his_dept dept,YY_ZGBMK yy ,ZY_BQDMK bq  where dept.id = zy.ksdm and zy.ysdm =yy.id and zy.bqdm = bq.id  and zy.hzxm ='" + patientName + "' and zy.sfzh='" + cardNumber + "' ";
	List<Map> result = QBuilder.db("basedb").queryHql(hql);
	for(Map map : result){
		String ssdm1 = null;
		if(map.get("ssdm1") != null){
			ssdm1 = map.get("ssdm1").toString();
		}
		String ssdm2 = null;
		if(map.get("ssdm2") != null){
			ssdm2 = map.get("ssdm2").toString();
		}
		StringBuffer sb = new StringBuffer();
		sb.append(ssdm1 == null ? "0" : ssdm1);
		sb.append(",");
		sb.append(ssdm2 == null ? "0" : ssdm2);
		List<Map> ssList = QBuilder.db("basedb").queryHql("select new map(ssmc as ssmc ) from SS_SSDJK where xh in(" + sb.toString() + ")");
		if(ssList != null || ssList.size() > 0){
			int i = 1;
			for(Map ssmap : ssList){
				String ssmc = ssmap.get("ssmc").toString();
				map.put("ssmc"+(i++),ssmc);
			}
		}
	}
	Message msg = new Message();
	msg.put("errcode",0);
	msg.put("data",result);
	out.println(msg);
%>